require "selenium-webdriver"
require "capybara/cucumber"
require "rspec"

Given(/^I am on backoffice login page$/) do
    visit('http://qatimemachine:8050/backoffice/login.htm')
end

When(/^I enter login details$/) do
    fill_in 'j_username', :with => "cs@tyro.com"
    fill_in 'j_password', :with => "admin"
end

When(/^I click login button$/) do
   click_button 'submit' 
end

Then(/^the page title should be "(.*?)"$/) do |page_title|
    page.should have_title(page_title)
end

Given(/^I am on merchant "(.*?)" homepage$/) do |merchant_name|
    merchant_id = get_merchant_id(merchant_name)
    visit("http://qadailytest:8050/backoffice/merchant/merchantHome.htm?mid=#{merchant_id}")
    fill_in 'j_username', :with => "cs@tyro.com"
    fill_in 'j_password', :with => "admin"
    click_button 'submit'
end

Then(/^I should see "(.*?)"$/) do |merchant_name_string|
    page.should have_content(merchant_name_string)
end
